﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace PIM_ATE.Mods
{
    public class ClsDataConfig
    {
        /// <summary>
        /// 测试标识
        /// </summary>
        public bool Enable { get; set; }
        /// <summary>
        /// 保存交调测试产品配置信息， 主键
        /// </summary>
        public int ID { get;  set; }
        /// <summary>
        /// 产品代码， 文本
        /// </summary>
        public string ProCode { get;  set; }

        #region 流程配置

        /// <summary>
        /// 测试顺序， 文本
        /// </summary>
        public int TestNo { get;  set; }
        /// <summary>
        /// 保存顺序， 文本
        /// </summary>
        public int SaveNo { get;  set; }
        /// <summary>
        /// 测试项名称， 文本
        /// </summary>
        public string PIMItemName { get;  set; }
        /// <summary>
        /// 交调类型：带内交调，带外交调， 其他
        /// </summary>
        public string PIMType { get;  set; }
        /// <summary>
        /// 通道
        /// </summary>
        public string ProCH { get;  set; }
        /// <summary>
        /// 关键工序：带内交调测试，带外交调测试
        /// </summary>
        public string KEYWP { get;  set; }
        /// <summary>
        /// 是否敲击, 是否
        /// </summary>
        public bool IsKnock { get;  set; }
        /// <summary>
        /// 提示信息
        /// </summary>
        public string Message { get;  set; }

        #endregion

        #region 互调配置

        /// <summary>
        /// 是否扫频， 是否
        /// </summary>
        public bool IsSweepTest { get;  set; }
        /// <summary>
        /// 交调阶数
        /// </summary>
        public string PIMOrder { get;  set; }
        /// <summary>
        /// 点频F1频率，文本
        /// </summary>
        public double F1Freq { get;  set; }
        /// <summary>
        /// 点频F2频率， 文本
        /// </summary>
        public double F2Freq { get;  set; }
        /// <summary>
        /// 点频测试PIM点频率
        /// </summary>
        public double PIMFreq { get;  set; }
        /// <summary>
        /// 扫频TX右边频点
        /// </summary>
        public double TXH { get;  set; }
        /// <summary>
        /// 扫频TX左边频点
        /// </summary>
        public double TXL { get;  set; }
        /// <summary>
        /// 扫频RX右边频点
        /// </summary>
        public double RXH { get;  set; }
        /// <summary>
        /// 扫频RX左边频点
        /// </summary>
        public double RXL { get;  set; }
        /// <summary>
        /// RX扫频步进, 单位Mhz
        /// </summary>
        public double RXStep { get;  set; }
        /// <summary>
        /// TX扫频步进1
        /// </summary>
        public double TestStep1 { get; set; }
        /// <summary>
        /// TX扫频步进2
        /// </summary>
        public double TestStep2 { get; set; }
        /// <summary>
        /// 测试时间（点频测试时间，点频敲击时间，扫频后点频敲击时间）,单位秒
        /// </summary>
        public int TestTime { get;  set; }
        /// <summary>
        /// 输出功率1
        /// </summary>
        public double F1Power { get;  set; }
        /// <summary>
        /// 输出功率2
        /// </summary>
        public double F2Power { get;  set; }
        /// <summary>
        /// 测试要求，使用区间表达
        /// </summary>
        public string SpecReg { get;  set; }
        /// <summary>
        /// 要求单位，dBc或dBm
        /// </summary>
        public string SpecUnit { get;  set; }

        /// <summary>
        /// 测试频段
        /// </summary>
        public string TestBand { get; set; }


        #endregion

        #region 补偿配置

        /// <summary>
        /// 产品增益
        /// </summary>
        public double ProGain { get;  set; }
        /// <summary>
        /// 校正值
        /// </summary>
        public double Check { get;  set; }
        /// <summary>
        /// 随机值
        /// </summary>
        public string Random { get;  set; }
        /// <summary>
        /// 功率补偿
        /// </summary>
        public double TXOffset { get; set; }
        #endregion

        #region 版本配置

        /// <summary>
        /// 工艺文件版本（要求版本）
        /// </summary>
        public string SpecVer { get;  set; }
        /// <summary>
        /// 配置版本
        /// </summary>
        public string ConfigVer { get;  set; }
        /// <summary>
        /// 生效时间
        /// </summary>
        public DateTime EffTime { get;  set; }
        /// <summary>
        /// 有效性， 是否
        /// </summary>
        public bool Effective { get;  set; }

        #endregion

        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get;  set; }

        public void setValues(int iID, string sCode, DataRow drConfigBuilderRow)
        {
            int i = 0;
            Enable = true;
            ID = iID;
            ProCode = sCode;
            TestNo = Convert.ToInt32(drConfigBuilderRow[i++].ToString());
            SaveNo = Convert.ToInt32(drConfigBuilderRow[i++].ToString());
            PIMItemName = drConfigBuilderRow[i++].ToString();
            PIMType = drConfigBuilderRow[i++].ToString();
            ProCH = drConfigBuilderRow[i++].ToString();
            KEYWP = drConfigBuilderRow[i++].ToString();
            IsSweepTest = PIMFunction.getBoolean(drConfigBuilderRow[i++].ToString());
            F1Freq = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            F2Freq = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            PIMFreq = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            TXH = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            TXL = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            RXH = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            RXL = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            F1Power = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            F2Power = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            PIMOrder = drConfigBuilderRow[i++].ToString();
            TestTime = Convert.ToInt32(drConfigBuilderRow[i++].ToString());
            RXStep = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            SpecReg = drConfigBuilderRow[i++].ToString();
            SpecUnit = drConfigBuilderRow[i++].ToString();
            IsKnock = PIMFunction.getBoolean(drConfigBuilderRow[i++].ToString());
            ProGain = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            Message = drConfigBuilderRow[i++].ToString();
            Check = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            Random = drConfigBuilderRow[i++].ToString();

            SpecVer = drConfigBuilderRow[i++].ToString();
            ConfigVer = drConfigBuilderRow[i++].ToString();
            EffTime = DateTime.Parse(drConfigBuilderRow[i++].ToString());
            Effective = PIMFunction.getBoolean(drConfigBuilderRow[i++].ToString());

            Remark = drConfigBuilderRow[i++].ToString();
            TXOffset = Convert.ToDouble(drConfigBuilderRow[i++].ToString());
            TestBand = drConfigBuilderRow[i++].ToString();
        }

        public void setRow(DataRow drConfigBuilderRow)
        {
            int i = 0;
            drConfigBuilderRow[i++] = TestNo;
            drConfigBuilderRow[i++] = SaveNo;
            drConfigBuilderRow[i++] = PIMItemName;
            drConfigBuilderRow[i++] = PIMType;
            drConfigBuilderRow[i++] = ProCH;
            drConfigBuilderRow[i++] = KEYWP;
            drConfigBuilderRow[i++] = IsSweepTest;
            drConfigBuilderRow[i++] = F1Freq;
            drConfigBuilderRow[i++] = F2Freq;
            drConfigBuilderRow[i++] = PIMFreq;
            drConfigBuilderRow[i++] = TXH;
            drConfigBuilderRow[i++] = TXL;
            drConfigBuilderRow[i++] = RXH;
            drConfigBuilderRow[i++] = RXL;
            drConfigBuilderRow[i++] = F1Power;
            drConfigBuilderRow[i++] = F2Power;
            drConfigBuilderRow[i++] = PIMOrder;
            drConfigBuilderRow[i++] = TestTime;
            drConfigBuilderRow[i++] = RXStep;
            drConfigBuilderRow[i++] = SpecReg;
            drConfigBuilderRow[i++] = SpecUnit;
            drConfigBuilderRow[i++] = IsKnock;
            drConfigBuilderRow[i++] = ProGain;
            drConfigBuilderRow[i++] = Message;
            drConfigBuilderRow[i++] = Check;
            drConfigBuilderRow[i++] = Random;

            drConfigBuilderRow[i++] = SpecVer;
            drConfigBuilderRow[i++] = ConfigVer;
            drConfigBuilderRow[i++] = EffTime.ToString("yyyy-MM-dd HH:mm:ss");
            drConfigBuilderRow[i++] = Effective;

            drConfigBuilderRow[i++] = Remark;
            drConfigBuilderRow[i++] = TXOffset;
            drConfigBuilderRow[i++] = TestBand;
        }
    }
}
